package com.sjn.cpu;
import com.sjn.cpu.cpuFrame.*;
import com.sjn.Template.composingRoom;
import com.sjn.res.egFoundry.*;
import com.sjn.res.egBlueprint.*;
import com.sjn.util.encrytion.*;
import com.sjn.res.make.*;


public class CPUcomposingRoom extends composingRoom {

    //创建加密模块
    encryForblueprint encryForblueprint = new encryForblueprint();
    @Override
    public String Foundry(int i) {
        //开始选择代工厂
        if(i==1) {
            egFoundry egFoundry = Foundryitem.getcpuFoundry(new egFoundryCPU1());
            return egFoundry.getFoundryName();
        }
        else if(i==2){
            egFoundry egFoundry = Foundryitem.getcpuFoundry(new egFoundryCPU2());
            return egFoundry.getFoundryName();
        }
        else{
            return "输入有误,选择代工厂失败";
        }
    }
    //

    @Override
    public String Blueprint(int x,int y,String technology) {
        //开始选择cpu蓝图
        bluePrintdata b = new bluePrintdemo(x,y,encryForblueprint.getdata(technology),new egbluePrintcpu());

        return b.draw();
    }

    @Override
    public String Frameworks(int i) {
        //单例+装饰模式,单例基础框架
        //装饰模式走起

        if(i == 1){
            cpuFrame cpuframe = cpuFramesin.getCpuframe(new cpuBaseF());

             return cpuframe.opreation();
        }

            //添加cpu基本框架,
        else if(i == 2){
                Decorator d1 = new Register(cpuFramesin.getCpuframe());
                return d1.opreation();
            }
            //添加寄存器
            else if(i == 3){
                Decorator d2 = new Controller(cpuFramesin.getCpuframe());
                return d2.opreation();
            }
            //添加控制器
            else if(i == 4){
                Decorator d3 = new ALU(cpuFramesin.getCpuframe());
                return d3.opreation();
            }
            //添加运算器
            else if(i == 5){
                Decorator d4 = new Clock(cpuFramesin.getCpuframe());
                return d4.opreation();
            }
            //添加时钟
            else {
                return "添加失败";
            }



    }

    @Override
    public String Production() {
        MakeFactory makeFactory = new MakeFactory();
        Makesth makecpu = makeFactory.getMake(new Makecpu());

        return makecpu.making();
    }

}
